package com.example.personnel_oa.controller;

import com.example.comment_oa.pojos.Positive;
import com.example.comment_oa.response.AjaxResponse;
import com.example.personnel_oa.service.PositiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
//控制器类
@CrossOrigin
//禁止Ajax访问当前站点外的资源
@Controller
//控制器
@RequestMapping("/personnelOa")
//跨域处理请求
public class PositiveController {
    @Autowired
    PositiveService positiveService;
    @GetMapping("/Positive/allpos")
    public AjaxResponse Methods_b(){
        AjaxResponse success = AjaxResponse.success(positiveService.Methods_b());
        System.err.println(success);
        return success;
    }
    @GetMapping("/Positive/allPositive")
    public AjaxResponse allPositive(){
            return AjaxResponse.success(positiveService.allPositive());
    }
    @GetMapping("/Positive/allcontract/{pid}")
    public AjaxResponse allcontract(@PathVariable("pid") int pid){
            return AjaxResponse.success(positiveService.allcontract(pid));
    }

    @PostMapping("Positive/insertadd")
    public AjaxResponse insertadd(@RequestBody Positive positive){
        int b = positiveService.insertadd(positive);
        return AjaxResponse.success(b);
    }

    @PostMapping("Positive/allpos")
    public AjaxResponse allpos(@RequestBody Positive positive){
        List<Positive> positives = positiveService.allpos(positive);
        return AjaxResponse.success(positives);
    }

    //根据工号查询转正审批数据详情
    @GetMapping("/Positive/posBianhao/{posBianhao}")
    public AjaxResponse posGonghao(@PathVariable("posBianhao") String posBianhao){
        return AjaxResponse.success(positiveService.posGonghao(posBianhao));
    }
}
